Những câu hỏi liên quan
Lê Tâm Anh
Xem chi tiết
gấu béo
7 tháng 5 2023 lúc 19:20

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

Bình luận (0)
Nguyễn Thị Tươi
Xem chi tiết
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

Bình luận (1)
Phan Đức Duy
Xem chi tiết
hacker
10 tháng 1 2021 lúc 17:31

uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.

Bình luận (0)
Minh Lệ
10 tháng 1 2021 lúc 20:09

Program HOC24;

var N:longint;

max,tg,t,d: integer;

Begin

write('Nhap N : '); readln(N);

max:=0;

while n<>0 do

begin

tg:=n mod 10;

d:=d+1;

t:=t+tg;

if tg>max then max:=tg;

n:=n div 10;

end;

writeln('So nguyen N co ',d,' chu so');

writeln('Tong cac chu so cua N la : ',t);

write('Chu so lon nhat cua N la :',max);

readln

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
10 tháng 1 2021 lúc 20:11

uses crt;

var n,d,i,t,max,x:longint;

y:integer;

st:string;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until n>0;

str(n,st);

d:=length(st);

writeln('So chu so cua ',n,' la: ',d);

t:=0;

max:=0;

for i:=1 to d do 

  begin

val(st[i],x,y);

t:=t+x;

if max<x then max:=x;

end;

writeln('Tong cac chu so cua ',n,' la: ',t);

writeln('Chu so lon nhat cua ',n,' la: ',max);

readln;

end.

Bình luận (0)
Lê Đăng Khôi
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 2 2023 lúc 15:39

1:

uses crt;

var t,x,i,n:integer;

begin

clrscr;

t:=0;

n:=10;

for i:=1 to n do

begin

readln(x);

t:=t+x;

end;

write(t);

readln;

end.

2: 

uses crt;

var dem,x,i,n:integer;

begin

clrscr;

dem:=0;

n:=10;

for i:=1 to n do

begin

readln(x);

if x mod 2=0 then inc(dem);

end;

write(dem);

readln;

end.

Bình luận (1)
Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 10:18

3

program Cacsole;
uses crt;
var M, N, i: integer;
begin
clrscr;
write ('Nhap M= '); readln(M);
write ('Nhap N= '); readln(N);
for i := M to N do

if  i mod 2 = 1 then
write (i,' ');
readln;
end.

Bình luận (1)
Bùi Lê Thanh Trúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 4 2022 lúc 8:21

uses crt;

var n,i,t,s:integer;

begin

clrscr;

repeat

readln(n);

until n<>0;

t:=0;

for i:=1 to n do if i mod 2=0 then t:=t+i;

writeln(t);

s:=1;

for i:=1 to n do 

  if i mod 2=1 then s:=s*i;

writeln(s);

readln;

end.

Bình luận (0)
Tống hiền chi
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 22:30

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem1,dem2;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

dem1=0;

dem2=0;

for (i=1; i<=n; i++)

{

if (a[i]%2==0) dem1++;

else dem2++;

}

cout<<dem1<<" "<<dem2;

return 0;

}

Bình luận (0)
Mạnh Quốc
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2023 lúc 7:43

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n;

cin>>n;

for (int i=1; i<=n; i++)

if (i%2==1) cout<<i<<" ";

return 0;

}

Bình luận (0)
Ngọc Ty
Xem chi tiết
Kiều Vũ Linh
24 tháng 4 2023 lúc 18:56

Var a:array[1..100] of integer;

i,n:integer;

s:longint;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap phan tu thu ',i,' = ');readln(a[i]);

s:=s+a[i];

End;

Write('Cac phan tu vua nhap la ');

For i:=1 to n do

Write(a[i]:8);

Writeln;

Write('Tong cua chung la ',s);

Readln

End.

Bình luận (0)